﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using GtsServer.Manage.Controller;
using GtsServer.Model;
using GtsServer.Common;

namespace GtsServer.Manage.IISPage.Ajax
{
    /// <summary>
    /// CommunicationReportAjax 的摘要说明
    /// </summary>
    public class CommunicationReportAjax : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            string type = string.Empty;
            if (context.Request["action"] != null)
            {
                type = context.Request["action"];

                switch (type)
                {
                    case "GetList":
                        GetList(context);
                        break;
                    default:
                        break;
                }
            }
        }

        private void GetList(HttpContext context)
        {
            string start = context.Request["StartTime"];
            string end = context.Request["EndTime"];
            int pid = string.IsNullOrEmpty(context.Request["pid"]) ? 0 : Convert.ToInt32(context.Request["pid"]);
            int pageIndex = Convert.ToInt32(context.Request["pageIndex"]);
            int pageSize = Convert.ToInt32(context.Request["pageSize"]);

            CommunicationReportController controller = new CommunicationReportController();
            int count = 0;
            List<CommunicationReport> list = controller.GetList(pageIndex, pageSize, pid, start, end, out count);
            context.Response.Write(JsonHelper.ListToJson<CommunicationReport>(list, count.ToString()));
        }
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}